from selenium import webdriver
from selenium.webdriver.common.by import By
import time
from selenium.webdriver import ActionChains


d = webdriver.Chrome()
d.get('https://www.qq.com')
d.maximize_window()
title = d.find_element(By.LINK_TEXT, '要闻')
res = d.find_element(By.CSS_SELECTOR, '[class=" bold"]')
a = res.text

res.click()
all_windows = d.window_handles
d.switch_to.window(all_windows[1])
res2 = d.find_element(By.CSS_SELECTOR, '[class="content-article"]')
b = res2.text
print(b)

d = webdriver.Chrome()
d.get('http://192.168.0.125:9009/')
js = "window.scrollTo(0,1000);"
d.execute_script(js)

dl = d.find_element(By.LINK_TEXT, '登录')
dl.click()
username = d.find_element(By.CSS_SELECTOR, '[name="log"]')
username.send_keys('admin')
password = d.find_element(By.CSS_SELECTOR, '[name="pwd"]')
password.send_keys('admin123')
time.sleep(2)
deng = d.find_element(By.CSS_SELECTOR, '[name="wp-submit"]')
deng.click()
text = d.find_element(By.LINK_TEXT, '文章')
ActionChains(d).move_to_element(text).perform()
w = d.find_element(By.LINK_TEXT, '写文章')
w.click()
a1 = d.find_element(By.CSS_SELECTOR, '[name="post_title"]')
a1.send_keys(a)
a2 = d.find_element(By.CSS_SELECTOR, '[id="content_ifr"]')
a2.send_keys()
push = d.find_element(By.CSS_SELECTOR, '')
push.click()
